//
//  AppDelegate.m
//  huien
//
//  Created by yiban on 2017/5/26.
//  Copyright © 2017年 lcb. All rights reserved.
//

#import "AppDelegate.h"
#import "AppDelegate+HE.h"
#import "HENavViewController.h"
#import "HEMainViewController.h"
#define appstore 1
@interface AppDelegate ()
@property(nonatomic,strong)HEMainViewController *mainVC;
@end

@implementation AppDelegate
- (BOOL)application:(UIApplication *)application didFinishLaunchingWithOptions:(NSDictionary *)launchOptions {
    // Override point for customization after application launch.
     [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleDefault];

//   [LcbDevice sharedLcbDevice].domain =@"http://huienziben.com:8000";
     [LcbDevice sharedLcbDevice].domain = @"http://test.huienziben.com";
    //
    [[JGShare sharedJGShare] initPush:launchOptions Appstore:appstore];

    //
    [[UIApplication sharedApplication] setStatusBarStyle:UIStatusBarStyleLightContent];
    self.window= [[UIWindow alloc] initWithFrame:[UIScreen mainScreen].bounds];
    self.window.backgroundColor=[UIColor whiteColor];
    [self enterMainPage];
    [self.window makeKeyAndVisible];
    [self getsureLogin];
    return YES;
}


- (void)applicationWillResignActive:(UIApplication *)application {
    // Sent when the application is about to move from active to inactive state. This can occur for certain types of temporary interruptions (such as an incoming phone call or SMS message) or when the user quits the application and it begins the transition to the background state.
    // Use this method to pause ongoing tasks, disable timers, and invalidate graphics rendering callbacks. Games should use this method to pause the game.
}


- (void)applicationDidEnterBackground:(UIApplication *)application {
    // Use this method to release shared resources, save user data, invalidate timers, and store enough application state information to restore your application to its current state in case it is terminated later.
    // If your application supports background execution, this method is called instead of applicationWillTerminate: when the user quits.
   
}


- (void)applicationWillEnterForeground:(UIApplication *)application {
    // Called as part of the transition from the background to the active state; here you can undo many of the changes made on entering the background.
     [self getsureLogin];
}

- (void)applicationDidBecomeActive:(UIApplication *)application{
    
}

- (void)applicationWillTerminate:(UIApplication *)application {
    // Called when the application is about to terminate. Save data if appropriate. See also applicationDidEnterBackground:.
}


- (void)application:(UIApplication *)app didRegisterForRemoteNotificationsWithDeviceToken:(NSData *)deviceToken {
    NSLog(@"My token is: %@", deviceToken);
#if !TARGET_IPHONE_SIMULATOR
    [JPUSHService registerDeviceToken:deviceToken];
#endif
}

- (void)application:(UIApplication *)app didFailToRegisterForRemoteNotificationsWithError:(NSError *)error {
   
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo {
#if !TARGET_IPHONE_SIMULATOR
    [JPUSHService handleRemoteNotification:userInfo];
#endif
}
- (void)application:(UIApplication *)application didReceiveRemoteNotification:(NSDictionary *)userInfo fetchCompletionHandler:(void (^)(UIBackgroundFetchResult))completionHandler {
#if !TARGET_IPHONE_SIMULATOR
    [JPUSHService handleRemoteNotification:userInfo];
#endif
    completionHandler(UIBackgroundFetchResultNewData);
}


- (BOOL)application:(UIApplication *)application handleOpenURL:(NSURL *)url
{
    return YES;
}
-(HEMainViewController*)mainVC
{
    if (!_mainVC) {
        _mainVC=[[HEMainViewController alloc] init];
    }
    return _mainVC;
}
//进入主页
-(void)enterMainPage
{
    self.window.rootViewController=nil;
//    _mainVC=[[HEMainViewController alloc] init];
    [self.mainVC setSelectTable:0];
    HENavViewController *navMe = [[HENavViewController alloc] initWithRootViewController:self.mainVC];
    self.window.rootViewController=navMe;
    
}
//进入主页
-(void)setSelectTable:(NSInteger)index
{
    [self.mainVC setSelectTable:index];
}
@end
